package minidb.file;
 
 
/**
* A reference to a disk block.
* A Block object consists of a block number.
* It does not hold the contents of the block;
* instead, that is the job of a Page object.
* @author zcx wangurey
*/
public class Block {
	private int blknum; 

	/**
	 * Constructs a block reference 
	 * for the specified filename and block number.
	 * @param blknum the block number
	 */
	public Block(int blknum) {
		this.blknum   = blknum;
	}

	/**
	 * Returns the location of the block within the file.
	 * @return the block number
	 */
	public int number() {
		return blknum;
	}

	public boolean equals(Object obj) {
		Block blk = (Block) obj;
		return blknum == blk.blknum;
	}

	public String toString() {
		return "block " + blknum + "";
	}

	public int hashCode() {
		return toString().hashCode();
	}
}